package 数据结构OJ;

public class 删除单链表指定元素_01_递归 {
    public class ListNode {
        int val;
        ListNode next;

        ListNode(int x) {
            val = x;
        }
    }
    public ListNode removeElements(ListNode head, int val) {
        if (head == null)
            return null;
        ListNode cur = removeElements(head.next, val);
        if (head.val == val)
            return cur;
        else {
            head.next = cur;
            return head;
        }
        //三目运算符版
        //head.next = had.val ==  val ? removeElements(head.next,val):removeElements(head,val);


    }
}
